      SUBROUTINE INTED(XP,YP,X1,Y1,X2,Y2,DH,DG,NG,INCA,INFA,
     &			NEAP,ID,J,alfa)
C
C Esta subrotina calcula o valor dos elementos fora da diagonal da
C matriz dH e dG atraves de integracao numerica ao longo dos elementos
C do contorno.
C
C R= Distancia do ponto em consideracao ate os pontos de integracao nos
C elementos de contorno.
C
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)

      DOUBLE PRECISION L, NX, NY, JE,alfa

      DIMENSION XCO(8),YCO(8),GI(8),OME(8),DR(2),L(2)

      IF (NG.EQ.8) THEN

         GI(1)=0.96028986
         GI(2)=-GI(1)
         GI(3)=0.79666648
         GI(4)=-GI(3)
         GI(5)=0.52553210
         GI(6)=-GI(5)
         GI(7)=0.18343464
         GI(8)=-GI(7)

         OME(1)=0.10122854
         OME(2)=OME(1)
         OME(3)=0.22238103
         OME(4)=OME(3)
         OME(5)=0.31370665
         OME(6)=OME(5)
         OME(7)=0.36268378
         OME(8)=OME(7)

      ELSE

         GI(1)=0.86113631
         GI(2)=-GI(1)
         GI(3)=0.33998104
         GI(4)=-GI(3)

         OME(1)=0.34785485
         OME(2)=OME(1)
         OME(3)=0.65214515
         OME(4)=OME(3)

      END IF

      BX= (X2 + X1) / 2.
      BY= (Y2 + Y1) / 2.

      XLX= (X2 - X1)
      XLY= (Y2 - Y1)

      AX= XLX / 2.
      AY= XLY / 2.

      XL= DSQRT( XLX**2 + XLY**2 )

      JE= XL / 2.

      NX= XLY / XL
      NY= -XLX / XL

      DG=0.
      DH=0.

      DO 10 I=1,NG

         XCO(I)= AX*GI(I) + BX
         YCO(I)= AY*GI(I) + BY

         RX= XCO(I) - XP
         RY= YCO(I) - YP

         R2=  RX**2 + RY**2
         R= DSQRT( R2 )

         UST=  alfa + DLOG(1/R)
         QST=  -(RX*NX + RY*NY) / R2

C
C  Calculo de dR, dN e dJe
C
      DR(1)= 0.
      DR(2)= 0.

      DNX= 0.
      DNY= 0.
      DJE= 0.

      L(1)= XLX
      L(2)= XLY

      IF (INCA.EQ.1) THEN

         SIGN= 1.
         IF(J.EQ.NEAP) SIGN= -1.

         DR(ID)= (1 - SIGN*GI(I)) / 2.
         DJE= -SIGN*L(ID) / (2*XL)

         IF (ID.EQ.1) THEN
            DNX= SIGN*(XLX*NX) / (XL*XL)
            DNY= SIGN*( (XLX*NY)/XL + 1)/XL
         ELSE
            DNX= SIGN*( (XLY*NX)/XL - 1)/XL
            DNY= SIGN*(XLY*NY) / (XL*XL)
         END IF
      END IF

      IF (INFA.EQ.1) THEN
         DR(ID)= DR(ID) - 0.5
      END IF

C
C  Calculo de dU* e dQ*
C

      A= (DR(1)*NX + DR(2)*NY + RX*DNX + RY*DNY) / R2

      B= ( (RX*NX +RY*NY) * (RX*DR(1) + RY*DR(2)) ) / (R2*R2)

      DQST= 2*B - A
      DUST= -(RX*DR(1) + RY*DR(2)) / R2

C
C  Calculo de dG e dH
C

         DG= DG + (JE*DUST + UST*DJE) * OME(I)
         DH= DH + (JE*DQST + QST*DJE) * OME(I)

 10   CONTINUE

      RETURN
      END